import java.io.IOException;
import java.net.Socket;
import java.util.Scanner;

public class DirectorThread extends Thread {
    ChatPanel chat;
    private Socket socket;
    private ChatQueue chatqueue;
    private GameQueue gamequeue;
    
	public DirectorThread(Socket socket, ChatQueue chatqueue, GameQueue gamequeue, ChatPanel panel) {
	        chat = panel;
	        this.socket = socket;
	        this.chatqueue = chatqueue;
	        this.gamequeue = gamequeue;
    }
	
	public void run() { 
		try { 
			Scanner sc = new Scanner(socket.getInputStream());
		    while (!sc.hasNext()) ;
		    int id = sc.nextInt();
		    
		    if(id < 7) { 
		    	ClientThread client = new ClientThread(sc, socket, chatqueue, chat, id);
                client.start();
		    }
		    
		    else {
		    	GameUpdaterThread updater = new GameUpdaterThread(sc, socket, gamequeue, chat, id);
		    	updater.start();
		    }
		} catch(IOException ioe) {}
	}
}